import request from "./request.js";
import { Decrypt } from '@/utils/aes.js'

// 获取标签课程
export function queryCourse(params) {
  return request({
    url: "/api/course/search",
    method: "POST",
    data: params,
    header: {
      "Content-Type": "application/json",
    },
  });
}

//获取新上好课数据
export function getNewCourse(params) {
  return request({
    url: "/api/course/mostNew",
    method: "POST",
    data: params,
    header: {
      "Content-Type": "application/json",
    },
  });
}

// 课程详情
export function getcourseInfo(courseId) {
  return request({
    url: "/api/course/getDetail",
    method: "get",
    params: { courseId },
  });
}

// 播放课程
export function playCourse(courseId, chapterId) {
  return request({
    url: "/api/player/play",
    method: "get",
    params: { courseId, chapterId },
    headers:{
        // 本地保存的accessToken   请求头的token
        'Authorization': Decrypt(localStorage.getItem('token')),
    }
  });
}
